package cn.mw.cmdb.view;

import cn.mw.cmdb.anno.CMDBHeader;
import cn.mw.cmdb.entity.InstanceInfoExtend;
import cn.mw.cmdb.entity.PropertyTypeSwitch;
import cn.mw.cmdb.entity.PropertyTypeTime;
import lombok.Data;

import java.util.Date;

@Data
public class StaticsViewInstance {

    @CMDBHeader(name = "序号")
    private int seq;

    @CMDBHeader(name = "ID")
    private String id;

    @CMDBHeader(name = "名称")
    private String mw_instanceName;

    @CMDBHeader(name = "IP")
    private String mw_inBandIp;

    @CMDBHeader(name = "模型分组名")
    private String modelGroupName;

    @CMDBHeader(name = "模型名")
    private String modelName;

    @CMDBHeader(name = "资产状态")
    private Boolean assetStatus;

    @CMDBHeader(name = "负责人")
    private String userNames;

    @CMDBHeader(name = "用户组")
    private String groupNames;

    @CMDBHeader(name = "机构/部门")
    private String orgNames;

    @CMDBHeader(name = "业务系统", visible = false)
    private String bussiness;

    @CMDBHeader(name = "告警区域", visible = false)
    private String alertArea;

    @CMDBHeader(name = "业务分类", visible = false)
    private String bussinessCatolog;

    @CMDBHeader(name = "模型Id", visible = false)
    private String modelId;

    @CMDBHeader(name = "创建人", visible = false)
    private String creater;

    @CMDBHeader(name = "创建时间", visible = false, propertyTypeId = PropertyTypeTime.ID)
    private Date createTime;

    @CMDBHeader(name = "是否关键设备", visible = false)
    private Boolean isKeyDevice;

    @CMDBHeader(name = "修改时间", visible = false, propertyTypeId = PropertyTypeTime.ID)
    private Date modificationTime;

    @CMDBHeader(name = "厂商", visible = false)
    private String vendor;

    @CMDBHeader(name = "描述", visible = false)
    private String description;

    @CMDBHeader(name = "规格型号", visible = false)
    private String specification;

    @CMDBHeader(name = "监控资产ID", visible = false)
    private String mw_monitorTypeId;

    @CMDBHeader(name = "监控服务器ID", visible = false)
    private String mw_monitorServerId;

    @CMDBHeader(name = "资产状态", visible = false)
    private String mw_itemAssetsStatus;

    @CMDBHeader(name = "监控状态", visible = false, propertyTypeId = PropertyTypeSwitch.ID)
    private Boolean mw_monitorFlag;

    @CMDBHeader(name = "监控服务器", visible = false)
    private String monitorServerName;

    @CMDBHeader(name = "轮训引擎Id", visible = false)
    private String mw_pollingEngine;

    @CMDBHeader(name = "轮训引擎", visible = false)
    private String pollingEngineName;

    @CMDBHeader(name = "监控方式", visible = false)
    private String mw_monitorMode;

    public void extractFromInstanceInfo(InstanceInfoExtend instanceInfo){
        this.id = instanceInfo.getId();
        this.mw_instanceName = instanceInfo.getInstanceName();
        this.mw_inBandIp = instanceInfo.getInBandIp();
        this.modelGroupName = instanceInfo.getModelGroupName();
        this.modelName = instanceInfo.getModelName();
        this.specification = instanceInfo.getSpecification();
        this.assetStatus = instanceInfo.getMonitorStatus();
        this.createTime = instanceInfo.getCreateTime();
        this.vendor = instanceInfo.getVendor();
        this.description = instanceInfo.getDesc();
        this.mw_monitorTypeId = instanceInfo.getMonitorTypeId();
        this.mw_itemAssetsStatus = instanceInfo.getItemAssetsStatus();
        this.mw_monitorFlag = instanceInfo.getMonitorStatus();
        this.mw_monitorMode = instanceInfo.getRuleType();
        this.modelId = instanceInfo.getModelId();
    }

}
